package com.qfedu.service.impl;

import com.qfedu.dao.DepartmentDao;
import com.qfedu.entity.Depart;
import com.qfedu.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartmentServiceImpl implements DepartmentService {

    @Autowired
    private DepartmentDao departmentDao;

    /**
     * 添加新部门
     *
     * @param depart
     * @return
     */
    @Override
    public int addDepartment(Depart depart) {
        return departmentDao.addDepartment(depart);
    }

    /**
     * 查询所有部门
     *
     * @return
     */
    @Override
    public List<Depart> findAllDepart() {
        return departmentDao.findAllDepart();
    }


    /**
     * 删除部门
     *
     * @param id
     * @return
     */
    @Override
    public boolean deleteDepartById(int id) {
        int num = departmentDao.deleteDepartById(id);
        if (num > 0) {
            return true;
        }
        return false;
    }

    /**
     * 更改部门信息
     *
     * @param depart
     * @return
     */
    @Override
    public int updateDepartment(Depart depart) {
        return departmentDao.updateDepartment(depart);
    }

}
